<template>
  <router-view />
  <van-config-provider>
    <van-tabbar v-model="active">
      <van-tabbar-item to="/" icon-prefix="icon" icon="movie"
        >电影</van-tabbar-item
      >
      <van-tabbar-item to="/cinema" icon-prefix="icon" icon="cinema"
        >影院</van-tabbar-item
      >
      <van-tabbar-item to="/consult" icon-prefix="icon" icon="consult"
        >资讯</van-tabbar-item
      >
      <van-tabbar-item to="/mine" icon-prefix="icon" icon="mime"
        >我的</van-tabbar-item
      >
    </van-tabbar>
  </van-config-provider>
</template>
<script setup>
import { onMounted, ref } from "vue";
import { useStore } from "vuex";
const store = useStore();
let active = ref(0);
onMounted(async () => {
  const tempCity = await fetch(
    "/map/ws/location/v1/ip?ip=117.136.52.222&key=LOBBZ-LFSWU-7OMV7-2OFVB-MFTX7-KGB66"
  );
  tempCity.json().then((res) => {
    let cityStr = res.result.ad_info.city;
    let enabled = false;
    const location = res.result.location;
    if (cityStr != "") {
      enabled = true;
      if (cityStr.indexOf("市") != -1) {
        cityStr = cityStr.substring(0, cityStr.indexOf("市"));
      }
    } else {
      cityStr = "武汉";
    }
    store.commit("updateLocation", location);
    store.commit("updateCity", cityStr);
    store.commit("updateLocateState", enabled);
    store.commit("updateShowTipState", enabled);
  });
});
</script>
<style>
@import "../src/assets/css/iconfont.css";
</style>
